import { defineConfig,loadEnv} from 'vite'
// @ts-ignore
import vue from '@vitejs/plugin-vue'
import path from 'path'
import viteCompression from 'vite-plugin-compression'

// https://vitejs.dev/config/
// @ts-ignore
export default ({ mode })=>{
	return defineConfig({
		plugins: [vue(), viteCompression()],
		resolve: {
			alias: {
				'@': path.resolve(__dirname, 'src'),
			},
		},
		server:{
			proxy: {
				'/api': {
					target: loadEnv(mode, process.cwd()).VITE_APP_WEB_URL,	//实际请求地址
					changeOrigin:true,
					rewrite: (path) => path.replace(/^\/api/, '')
				},
			},
		}
	})
}
